package com.gkzf.ai.module.crm.controller.app.simpleCredit;

import com.gkzf.ai.framework.common.pojo.CommonResult;
import com.gkzf.ai.framework.common.util.object.BeanUtils;
import com.gkzf.ai.module.crm.controller.app.simpleCredit.vo.house.UserAdmittanceHouseRespVO;
import com.gkzf.ai.module.crm.dal.dataobject.creditreportsimple.UserAdmittanceHouseDO;
import com.gkzf.ai.module.crm.service.creditreportsimple.app.AppUserAdmittanceHouseService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.gkzf.ai.framework.common.pojo.CommonResult.success;

@Tag(name = "App后台 - CRM 小程序补充信息-房产")
@RestController
@RequestMapping("/app/user-admittance-house")
@Validated
public class UserAdmittanceHouseController {

    @Resource
    private AppUserAdmittanceHouseService appUserAdmittanceHouseService;


    @PutMapping("/update")
    @Operation(summary = "更新/添加 小程序补充信息-房产")
    public CommonResult<Boolean> updateUserAdmittanceHouse(@Valid @RequestBody List<UserAdmittanceHouseDO> updateReqVO) {
        appUserAdmittanceHouseService.updateUserAdmittanceHouse(updateReqVO);
        return success(true);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除 小程序补充信息-房产")
    @Parameter(name = "id", description = "编号", required = true)
    public CommonResult<Boolean> deleteUserAdmittanceHouse(@RequestParam("id") Long id) {
        appUserAdmittanceHouseService.deleteUserAdmittanceHouse(id);
        return success(true);
    }

    @GetMapping("/list")
    @Operation(summary = "获得 小程序补充信息-房产集合")
    public CommonResult<List<UserAdmittanceHouseRespVO>> getUserAdmittanceHouseList(@RequestParam("userOpenId") String userOpenId) {
        List<UserAdmittanceHouseDO> pageResult = appUserAdmittanceHouseService.getUserAdmittanceHouseList(userOpenId);
        return success(BeanUtils.toBean(pageResult, UserAdmittanceHouseRespVO.class));
    }
    

}